package com.example.reference_book.controller;

import com.example.reference_book.entity.Book;
import com.example.reference_book.service.BookService;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Primary
@RestController
@RequestMapping("searchBookTagStrategy")
public class searchBookTagStrategy implements BookStrategy {

    @Resource
    private BookService bookService;

    @GetMapping("/{type}/{key}")
    @Override
    public List<Book> searchByType(@PathVariable("type") String type, @PathVariable("key") String key) {
        return this.bookService.queryByTag(type,key);
        //return null;
    }
}

